<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>
<%@ page import="performReservation.SMMDBBean"%>
<%@ page import="java.sql.*"%>

<jsp:useBean id="cus" scope="page" class="performReservation.Customer"/>
<jsp:useBean id="admin" scope="page" class="performReservation.Admin"/>
<%
	Cookie cookies[] = request.getCookies();
%>
<%
	String email =null;
	String type = null;
	if(cookies != null){
		for(int i=0 ; i < cookies.length; i++){
			if(cookies[i].getName().equals("email")){
				email = cookies[i].getValue();
			}else if(cookies[i].getName().equals("type")){
				type = cookies[i].getValue();
			}
		}	
	
		if(email == null){
			response.setHeader("Error","");
			out.println("Unexcept Error!!");
		}else if(type.equals("cus")){
			cus.setEmail(email);
			SMMDBBean mProcess = SMMDBBean.getInstance();
			boolean b = mProcess.deleteCustomer(cus);
			if (b){
				response.setHeader("Exit Successfully","");
				out.println("You are not member of this site");
				%>
				<jsp:forward page="login.jsp" />
			<%
			}else{%>
				<jsp:forward page="userDashboard.jsp" />
			<% }
		}else if(type.equals("admin")){
			admin.setEmail(email);
			SMMDBBean mProcess = SMMDBBean.getInstance();
			boolean b = mProcess.deleteAdmin(admin);
			if (b){
				response.setHeader("Exit Successfully","");
				out.println("You are not admin of this site");
				%>
				<jsp:forward page="login.jsp" />
			<%
			}else{%>
				<jsp:forward page="adminDashboard.jsp" />
			<% }
		}
	}else
%>
<jsp:forward page="userDashboard.jsp" /><% ; %>